﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Caculator : Form
    {
        public Caculator()
        {
            InitializeComponent();
            
        }

        
        
        private void button1_Click(object sender, EventArgs e)
        {
            // 从文本框中获取输入的数组
            string[] inputArray = textBox1.Text.Split(',');

            // 将输入的数组转换为整数数组
            int[] numbers = Array.ConvertAll(inputArray, int.Parse);

            // 计算最大值
            int max = numbers.Max();

            // 计算最小值
            int min = numbers.Min();

            // 计算平均值
            double average = numbers.Average();

            // 计算所有元素的总和
            int sum = numbers.Sum();

            // 在输出标签中显示结果
            MaxLabel.Text = "最大值：" + max;
            MinLabel.Text = "最小值：" + min;
            AverageLabel.Text = "平均值：" + average;
            SumLabel.Text = "总和：" + sum;
        }

        private void SumLabel_Click(object sender, EventArgs e)
        {

        }
    }
}
